/*
 * @Author: fisher
 * @Date: 2024-01-12 09:36:07
 * @LastEditTime: 2024-01-12 10:58:42
 * @LastEditors: fisher
 * @Description:
 * @FilePath: \front-end-template\src\modules\DataManage\utils\download.js
 */

import axios from "axios";
import storage from "@/utils/storage";
import store from "@/store/index.js";
export const downloadWithProgress = (token) => {
  let progressRatio = "";
  return axios({
    url: `/api/converter/common/filerecord/down?FileToken=${token}`,
    method: "get",
    responseType: "blob",
    headers: {
      "Fawkes-Auth": `${storage.get("access_token")}`,
    },
    onDownloadProgress(progress) {
      progressRatio = Math.round((100 * progress.loaded) / progress.total);
      store.commit("setDownloadProgress", progressRatio);
    },
  });
};
